package com.gaomall.seckill.controller;

import com.gaomall.seckill.domain.Users;
import com.gaomall.seckill.enums.ResponseStatusCode;
import com.gaomall.seckill.exception.CommonException;
import com.gaomall.seckill.service.IUserService;
import com.gaomall.seckill.service.impl.UserServiceImpl;
import com.gaomall.seckill.utils.ResultVOUtil;
import com.gaomall.seckill.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.apache.commons.lang3.StringUtils;

@RestController
public class RegisterController extends BaseController{

    //用户注册接口
    @RequestMapping(value = "/register", method = {RequestMethod.POST}, consumes = {CONTENT_TYPE_FORMED})
    @ResponseBody
    public ResultVO register(@RequestParam(name = "telphone") String telphone,
                             @RequestParam(name = "password") String password) {

        //入参校验
        if (StringUtils.isEmpty(telphone) || StringUtils.isEmpty(password)) {
            throw new CommonException(ResponseStatusCode.PARAMETER_VALIDATION_ERROR);
        }


        //用户的注册流程
        Users Users = new Users();
        Users.setTelphone(telphone);
        //密码加密
        Users.setPasswd(password);

//        UserService.register(Users);
        return ResultVOUtil.success("注册成功");
    }

}
